home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
Foible
/
SDS
/
SDS-Graphs.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
27KB
|
1,048 lines
Model subclass: #Graph
instanceVariableNames: 'label plotVariables timeVariable graphBox graphOffset form view '
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
Graph comment:
'I am a model for two dimension graph.
Instance variables:
label <String>
label to appear in graph window
plotVariables <OrderedCollection of PlotVariable>
what dependence variables to draw in graph (y axis values)
timeVariable <TimeVariable>
time definition to draw as x axis
graphBox <Rectangular>
size of the graph drawing
graphOffset <Point>
offset of graphBox relative to the view.
'!
!Graph methodsFor: 'initialize'!
initialize
"initialize graph model, set all defaults"
self form: (Form new extent: 550@300).
self graphBox: (0@0 extent: 400@200).
self graphOffset: 100@50.! !
!Graph methodsFor: 'displaying'!
display
"Draw everything to receiver form"
self displayTimeScale.
self displayPlotScale.
self displayPlotVariableNames.
self plotVariables do:
[:aPlotVariable | aPlotVariable plotOn: self form].!
displayOn: aView
"Display what already in form to aView"
self form
displayOn: Display
at: (aView displayTransformation applyTo: 0 @ 0)
clippingBox: (aView displayTransformation applyTo: (0 @ 0 extent: 550 @ 300))
rule: Form over
mask: Form black!
displayPlotScale
"display plot scale on y axis"
| aLine intervals translation aLine2 aLine4 aLine8 currentPoint numberOfPlotVariables maxPoint minPoint |
aLine := Line new.
aLine beginPoint: self graphOffset - (1 @ 0).
aLine endPoint: self graphOffset + (-1 @ self graphBox extent y).
aLine
displayOn: form
at: 0 @ 0
clippingBox: form boundingBox
rule: Form over
mask: Form black.
aLine
displayOn: form
at: graphBox extent x @ 0
clippingBox: form boundingBox
rule: Form over
mask: Form black.
aLine2 := Line new.
aLine2 endPoint: -2 @ 0.
aLine4 := Line new.
aLine4 endPoint: -4 @ 0.
aLine8 := Line new.
aLine8 endPoint: -8 @ 0.
intervals := 32.
translation := aLine beginPoint - aLine endPoint / intervals.
currentPoint := aLine beginPoint.
0 to: intervals do:
[:index |
(index rem: 4)
= 0
ifTrue:
[aLine8
displayOn: form
at: currentPoint
clippingBox: form boundingBox
rule: Form over
mask: Form black.
aLine8
displayOn: form
at: currentPoint + ((8 + graphBox extent x) @ 0)
clippingBox: form boundingBox
rule: Form over
mask: Form black]
ifFalse: [(index rem: 2)
= 0
ifTrue:
[aLine4
displayOn: form
at: currentPoint
clippingBox: form boundingBox
rule: Form over
mask: Form black.
aLine4
displayOn: form
at: currentPoint + ((4 + graphBox extent x) @ 0)
clippingBox: form boundingBox
rule: Form over
mask: Form black]
ifFalse:
[aLine2
displayOn: form
at: currentPoint
clippingBox: form boundingBox
rule: Form over
mask: Form black.
aLine2
displayOn: form
at: currentPoint + ((2 + graphBox extent x) @ 0)
clippingBox: form boundingBox
rule: Form over
mask: Form black]].
currentPoint := currentPoint - translation].
numberOfPlotVariables := self plotVariables size.
maxPoint := 5 @ (graphOffset y - (numberOfPlotVariables * 7) + 6).
minPoint := maxPoint + (0 @ self graphBox extent y).
translation := 0 @ 14.
self plotVariables do:
[:aPlotVariable |
aPlotVariable displayMinimumOn: self form at: minPoint; displayMaximumOn: self form at: maxPoint.
maxPoint := maxPoint translateBy: translation.
minPoint := minPoint translateBy: translation]!
displayPlotVariableNames
"display legend for plot variables"
| index aPoint |
index := 0.
aPoint := 10@10.
self plotVariables do:
[:aVar |
aVar displayNameOn: self form at: aPoint.
index := index + 1 rem: 4.
index isZero
ifTrue: [aPoint := 10 @ (aPoint y + 15)]
ifFalse: [aPoint := aPoint + (125 @ 0)]]!
displayTimeScale
"Display time scale of reciever."
self timeVariable
displayOn: self form
from: self graphOffset + (0 @ (self graphBox extent y + 1))
to: self graphOffset + self graphBox extent + (0 @ 1)! !
!Graph methodsFor: 'accessing'!
form
"Answer the form"
^form.!
form: aForm
"set form where to draw"
form := aForm.!
graphBox
"Answer graphBox"
^graphBox.!
graphBox: aRectangle
"set graphBox size"
graphBox := aRectangle.!
graphOffset
"Answer graphOffset"
^graphOffset.!
graphOffset: aPoint
"set graphOffset"
graphOffset := aPoint.!
label
"Answer the label"
^label.!
label: aString
"set label for graph"
label := aString!
plotVariables
"Answer plotVariables Collection"
^plotVariables.!
plotVariables: aPlotVariableCollection
"Set plotVariables of receiver"
plotVariables := aPlotVariableCollection.!
timeVariable
"Answer timeVar"
^timeVariable!
timeVariable: aTimeVariable
"Set timeVariable of receiver"
timeVariable := aTimeVariable.!
view
"answer the corressponding view"
^view.!
view: aGraphView
"set corresponding view"
view := aGraphView.! !
!Graph methodsFor: 'adding'!
addPlotVariable: aPlotVariable
"Add a plotVariable to plotVariables Collection"
self plotVariables = nil
ifTrue: [self plotVariables: OrderedCollection new].
self plotVariables addLast: aPlotVariable.!
addPlotVariableWithName: aString minimum: minimumValue maximum: maximumValue data: anOC mask: aMask
"Add a plotVariable to plotVariables Collection"
| aPlotVariable minValue maxValue |
minimumValue = maximumValue
ifTrue: [minValue _ minimumValue -1.
maxValue _ maximumValue + 1]
ifFalse:[minValue _ minimumValue.
maxValue _ maximumValue].
self timeVariable = nil
ifTrue: [self error: 'time range not defined']
ifFalse:
[aPlotVariable := PlotVariable new.
aPlotVariable name: aString; minimum: minValue; maximum: maxValue.
aPlotVariable data: anOC.
aPlotVariable boundingBox: (self graphBox translateBy: self graphOffset).
aPlotVariable transformation: (WindowingTransformation window: (0 @ minValue corner: self timeVariable numberOfIntervals @ maxValue) viewport: self graphBox).
aPlotVariable mask: aMask.
self plotVariables = nil
ifTrue: [self plotVariables: OrderedCollection new].
self plotVariables addLast: aPlotVariable.]!
addPlotVariableWithName: aString minimum: minValue maximum: maxValue mask: aMask
"Add a plotVariable to plotVariables Collection"
| aPlotVariable |
self timeVariable = nil
ifTrue: [self error: 'time range not defined']
ifFalse:
[aPlotVariable := PlotVariable new.
aPlotVariable name: aString; minimum: minValue; maximum: maxValue.
aPlotVariable data: OrderedCollection new.
aPlotVariable boundingBox: (self graphBox translateBy: self graphOffset).
aPlotVariable transformation: (WindowingTransformation window: (0 @ minValue extent: self timeVariable numberOfIntervals @ maxValue) viewport: self graphBox).
aPlotVariable mask: aMask.
self plotVariables = nil
ifTrue: [self plotVariables: OrderedCollection new].
self plotVariables addLast: aPlotVariable.]!
timeVariableWithMinimum: minValue maximum: maxValue delta: aDelta
"Add a plotVariable to plotVariables Collection"
| aTimeVariable |
aTimeVariable := TimeVariable new.
aTimeVariable name: 'Time'.
aTimeVariable minimum: minValue; maximum: maxValue; delta: aDelta.
self timeVariable: aTimeVariable.! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
Graph class
instanceVariableNames: ''!
!Graph class methodsFor: 'mask constants'!
mask: aNumber
aNumber = 0
ifTrue: [^Form black].
aNumber = 1
ifTrue: [^Form darkGray].
aNumber = 2
ifTrue: [^Form gray].
aNumber = 3
ifTrue: [^Form veryLightGray].! !
!Graph class methodsFor: 'user interface'!
example
"example"
"Graph example"
| anOC aGraphVariable aGraph anOCOC anOC2 anOC3 |
aGraph := Graph new.
anOC := OrderedCollection new.
anOC add: 10; add: 20; add: 5; add: 15; add: 40; add: 50.
anOC2 := OrderedCollection new.
anOC2 add: 30; add: 40; add: 25; add: 40; add: 40; add: 90; add: 100; add: 20.
anOC3 := OrderedCollection new.
anOC3 add: 130; add: 240; add: 125; add: 540; add: 40; add: 590; add: 100; add: 20; add: 349.
aGraph graphBox: (0@0 extent: 400@200).
aGraph graphOffset: (50@50).
aGraphVariable := GraphVariable newWithLabel: 'test' minimum: 0 maximum: 100 data: anOC maxT: 5 deltaT: 1 graphBox: aGraph graphBox.
aGraphVariable mask: Form black.
anOCOC := OrderedCollection new.
anOCOC add: aGraphVariable.
aGraphVariable := GraphVariable newWithLabel: 'test23' minimum: 0 maximum: 100 data: anOC2 maxT: 7 deltaT: 1 graphBox: aGraph graphBox.
aGraphVariable mask: Form gray.
anOCOC add: aGraphVariable.
aGraphVariable := GraphVariable newWithLabel: 'test34' minimum: 100 maximum: 600 data: anOC3 maxT: 15 deltaT: 1 graphBox: aGraph graphBox.
aGraphVariable mask: Form darkGray.
anOCOC add: aGraphVariable.
aGraphVariable := GraphVariable newWithLabel: 'test56' minimum: 000 maximum: 900 data: anOC3 maxT: 40 deltaT: 1 graphBox: aGraph graphBox.
aGraphVariable mask: Form gray.
anOCOC add: aGraphVariable.
aGraphVariable := GraphVariable newWithLabel: 'test67' minimum: 80 maximum: 600 data: anOC3 maxT: 10 deltaT: 1 graphBox: aGraph graphBox.
aGraphVariable mask: Form darkGray.
anOCOC add: aGraphVariable.
aGraph dependentVars: anOCOC.
GraphView openOn: aGraph.!
test
"Graph test"
| aGraph |
aGraph := Graph new.
aGraph initialize.
aGraph label: 'Graph'.
aGraph timeVariableWithMinimum: 0 maximum: 100 delta: 5.
aGraph addPlotVariableWithName: 'test1' minimum: 0 maximum: 100 mask: Form black.
aGraph plotVariables first add: 10; add: 20; add: 10; add: 50; add:90; add:30; add:20.
aGraph display.
GraphView openOn: aGraph.! !
Object subclass: #GraphVariable
instanceVariableNames: 'name minimum maximum '
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
GraphVariable comment:
'I am an abstract superclass for graph variables (either dependent variables for y axis, or independent variable for x axis)
Instance variables
name <String>
variable name
minimum <Number>
minimum boundary to be shown in the graph
maximum <Number>
similar to above for maximum boundary'!
!GraphVariable methodsFor: 'displaying'!
displayNameOn: aForm at: aPoint
"Display variable name."
self name displayOn: aForm at: aPoint.! !
!GraphVariable methodsFor: 'accessing'!
maximum
"Answer maximum value of receiver"
^maximum!
maximum: maxValue
"Set maximum value of receiver"
maximum := maxValue.!
minimum
"Answer minimum value of receiver"
^minimum!
minimum: minValue
"Set minimum value of receiver"
minimum := minValue.!
name
"Answer name of variable "
^name.!
name: aString
"define the name of variable "
name := aString.! !
GraphVariable subclass: #TimeVariable
instanceVariableNames: 'delta '
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
TimeVariable comment:
'I define the x-axis values for the graph.
Instance variable:
delta <Number>
delta time '!
!TimeVariable methodsFor: 'displaying'!
displayOn: aForm from: aPoint to: anotherPoint
"display time scale on x axis"
| aLine intervals translation aLine2 aLine4 aLine8 currentPoint aNumber |
aLine := Line new.
aLine beginPoint: aPoint; endPoint: anotherPoint.
aLine
displayOn: aForm
at: 0 @ 0
clippingBox: aForm boundingBox
rule: Form over
mask: Form black.
aLine2 := Line new.
aLine2 endPoint: 0 @ 2.
aLine4 := Line new.
aLine4 endPoint: 0 @ 4.
aLine8 := Line new.
aLine8 endPoint: 0 @ 8.
intervals := 32.
translation := anotherPoint - aPoint / intervals.
currentPoint := aPoint.
0 to: intervals do:
[:index |
(index rem: 4)
= 0
ifTrue: [aLine8
displayOn: aForm
at: currentPoint
clippingBox: aForm boundingBox
rule: Form over
mask: Form black]
ifFalse: [(index rem: 2)
= 0
ifTrue: [aLine4
displayOn: aForm
at: currentPoint
clippingBox: aForm boundingBox
rule: Form over
mask: Form black]
ifFalse: [aLine2
displayOn: aForm
at: currentPoint
clippingBox: aForm boundingBox
rule: Form over
mask: Form black]].
currentPoint := currentPoint + translation].
minimum printString displayOn: aForm at: aPoint + (-5 @ 10).
translation := translation * 8.
currentPoint := aPoint + (-10 @ 10).
aNumber := (maximum - minimum / 4) asFloat.
1 to: 3 do:
[:index |
currentPoint := currentPoint + translation.
(minimum + (index * aNumber)) printString displayOn: aForm at: currentPoint].
maximum printString displayOn: aForm at: anotherPoint + (-10 @ 10).
name displayOn: aForm at: aPoint + anotherPoint / 2 + (-10 @ 25)! !
!TimeVariable methodsFor: 'accessing'!
delta
"Answer delta X value of receiver"
^delta!
delta: aNumber
"Set delta X value of receiver"
delta := aNumber.!
numberOfIntervals
"Answer number of intervals in time variable"
^self maximum - self minimum / self delta! !
GraphVariable subclass: #PlotVariable
instanceVariableNames: 'mask transformation boundingBox data '
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
PlotVariable comment:
'I am a variable to be plotted in a graph (variable as y axis).
Instance variables
mask <Form>
mask (''color'') for plotting my values
transformation <WindowingTransformation>
transform my values to point in the view
boundingBox <Rectangular>
clipping box of the plot line
data <OrderedCollection of Number>
my ordered values over time'!
!PlotVariable methodsFor: 'adding'!
add: aValue
"Append a new value to receiver data"
self data = nil
ifTrue: [self data: OrderedCollection new].
self data addLast: aValue.! !
!PlotVariable methodsFor: 'displaying'!
add: aValue plotOn: aDisplayMedium
"add a new value and plot receiver on display medium."
| aLine baseY aPoint aBoundingBox lastIndex |
aBoundingBox := self boundingBox.
baseY := aBoundingBox extent y.
aPoint := aBoundingBox origin.
aLine := Line new.
aLine form: (Form dotOfSize: 2).
lastIndex := self data size - 1.
aLine beginPoint: (self transformation applyTo: lastIndex @ self data last).
aLine endPoint: (self transformation applyTo: lastIndex + 1 @ aValue).
aLine beginPoint y: baseY - aLine beginPoint y.
aLine endPoint y: baseY - aLine endPoint y.
aLine
displayOn: aDisplayMedium
at: aPoint
clippingBox: aBoundingBox
rule: Form over
mask: self mask.
self add: aValue.!
displayMaximumOn: aForm at: aPoint
| aLine |
aLine := Line new.
aLine form: (Form dotOfSize: 2).
aLine beginPoint: 0@0; endPoint: 5@0.
aLine displayOn: aForm at: aPoint clippingBox: aForm boundingBox rule: Form over mask: self mask.
self maximum printString displayOn: aForm at: (aPoint + (8@-8)).!
displayMinimumOn: aForm at: aPoint
| aLine |
aLine := Line new.
aLine form: (Form dotOfSize: 2).
aLine beginPoint: 0@0; endPoint: 5@0.
aLine displayOn: aForm at: aPoint clippingBox: aForm boundingBox rule: Form over mask: self mask.
self minimum printString displayOn: aForm at: (aPoint + (8@-8)).!
displayNameOn: aForm at: aPoint
| aLine |
aLine := Line new.
aLine form: (Form dotOfSize: 2).
aLine beginPoint: 0@0; endPoint: 25@0.
aLine displayOn: aForm at: aPoint clippingBox: aForm boundingBox rule: Form over mask: self mask.
self name displayOn: aForm at: (aPoint + (30@-8)).!
plotOn: aDisplayMedium
"Plot receiver on display medium."
| aLine nextIndex nextPoint baseY aPoint aBoundingBox counter |
(data = nil) | (data size = 0) ifTrue: [^nil].
aBoundingBox := self boundingBox.
baseY := aBoundingBox extent y.
aPoint := aBoundingBox origin.
aLine := Line new.
aLine form: (Form dotOfSize: 2).
nextIndex := 0.
nextPoint := self transformation applyTo: nextIndex @ data first.
nextPoint y: baseY - nextPoint y.
counter := 1.
self data do:
[:datum |
counter < self data size
ifTrue:
[aLine beginPoint: nextPoint.
nextIndex := nextIndex + 1.
nextPoint := self transformation applyTo: nextIndex @ (data after: datum).
nextPoint y: baseY - nextPoint y.
aLine endPoint: nextPoint.
aLine
displayOn: aDisplayMedium
at: aPoint
clippingBox: aBoundingBox
rule: Form over
mask: self mask].
counter := counter + 1]! !
!PlotVariable methodsFor: 'accessing'!
boundingBox
"Answer boundingBox of receiver"
^boundingBox.!
boundingBox: aRectangle
"Set boundingBox of receiver"
boundingBox := aRectangle.!
data
"Answer ordered collection data of receiver"
^data.!
data: anOrderedCollection
"Set ordered collection data of receiver"
data := anOrderedCollection.!
mask
"Answer mask information of receiver"
^mask.!
mask: aForm
"Set mask information of receiver"
mask := aForm.!
transformation
"Answer transformation of receiver"
^transformation.!
transformation: aWindowingTransformation
"Set transformation of receiver"
transformation := aWindowingTransformation.! !
Model subclass: #GraphList
instanceVariableNames: 'currentBox boxes '
classVariableNames: 'BoxMenu '
poolDictionaries: ''
category: 'SDS-Graphs'!
GraphList comment:
'I am the model for editing graph parameters (what variables to appear in graph and what their the minimum / maximum boundaries).
Instance variables:
boxes <OrderedCollection of SDSBox-es>
holds what boxes already enrolled to appear in graph
currentBox <String>
current box''s name whose variable is being edited
Class variable:
BoxMenu <ActionMenu>
menu for the leftmost subview (the right part of the view is a MinMaxView)
'!
!GraphList methodsFor: 'box list'!
boxList
"Answer an Array of my boxes name"
| anArray index |
anArray _ Array new: boxes size.
index _ 1.
boxes do:
[:box |
anArray at: index put: box name.
index _ index + 1].
^anArray!
boxMenu
"Answer box menu"
BoxMenu = nil ifTrue: [BoxMenu _ ActionMenu labels: 'delete' selectors: #(#deleteBox )].
^BoxMenu!
boxValue
"Answer my box whose name is equal to currentBox"
boxes do: [:box | box name asString = currentBox ifTrue: [^box]].
^nil!
currentBox
^currentBox!
currentBox: aSelection
currentBox _ aSelection.
self changed: #forBox: with: self boxValue.! !
!GraphList methodsFor: 'accessing'!
boxes
^boxes!
boxes: anOCBoxes
boxes _ anOCBoxes! !
!GraphList methodsFor: 'private-menu messages'!
deleteBox
"delete currentBox"
boxes remove: self boxValue ifAbsent: [^nil].
self changed: #currentBox! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
GraphList class
instanceVariableNames: ''!
!GraphList class methodsFor: 'instance creation'!
withBoxes: anOCBoxes
"Answer an instance of the receiver on the model, aGraphList.
The label is aString. Do not terminate the current active process."
| topView aGraphList aMinMaxEditor |
aGraphList _ GraphList new.
aGraphList boxes: anOCBoxes.
aMinMaxEditor _ MinMaxEditor new.
aGraphList addDependent: aMinMaxEditor.
topView _ StandardSystemView
model: aGraphList
label: 'List of Plotted Variables'
minimumSize: 300 @ 100.
topView
addSubView: (SelectionInListView
on: aGraphList
printItems: true
oneItem: false
aspect: #currentBox
change: #currentBox:
list: #boxList
menu: #boxMenu
initialSelection: #currentBox)
in: (0 @ 0 extent: 0.4 @ 1)
borderWidth: 1.
MinMaxView
view: aMinMaxEditor
in: (0.4 @ 0 extent: 1 @ 1)
of: topView.
topView controller open.
^topView! !
InspectorView subclass: #MinMaxView
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
MinMaxView comment:
'View for editing the minimum and maximum boundaries of a variable in graph.
I am part of triad MVC with MinMaxEditor(model) and MinMaxController(controller).'!
!MinMaxView methodsFor: 'controller access'!
defaultController
^model defaultControllerClass new.! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
MinMaxView class
instanceVariableNames: ''!
!MinMaxView class methodsFor: 'private'!
buildScheduledView: aMinMaxEditor
| topView |
topView _ self
model: aMinMaxEditor
label: 'Graph parameters for: ' , aMinMaxEditor box name
minimumSize: 180 @ 180.
self
view: aMinMaxEditor
in: (0 @ 0 extent: 1 @ 1)
of: topView.
^topView! !
StandardSystemView subclass: #GraphView
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
GraphView comment:
'View for graph window.'!
!GraphView methodsFor: 'displaying'!
display
self model displayOn: self.
self halt.!
displayView
super displayView.
self halt.! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
GraphView class
instanceVariableNames: ''!
!GraphView class methodsFor: 'instance creation'!
openOn: aGraph
"Answer an instance of the receiver on the model"
| topView aFormView |
"aGraph initialize."
topView := StandardSystemView
model: aGraph
label: aGraph label
minimumSize: 554 @ 304.
aFormView := FormView new model: aGraph form controller: NoController new.
topView addSubView: aFormView.
topView borderWidth: 2.
"aGraph displayOn: aFormView."
topView controller open.
^topView! !
Inspector subclass: #MinMaxEditor
instanceVariableNames: 'minimum maximum box '
classVariableNames: 'FieldList MinMaxTextMenu '
poolDictionaries: ''
category: 'SDS-Graphs'!
MinMaxEditor comment:
'Model for editing the minimum and maximum boundary values to be shown in the graph.
Instance variables
minimum <Number>
current minimum value or a string ''default (X)'' where X is default
minimum value
maximum <Number>
current maximum value
box <SDSBox>
box which minimum/maximum values being defined
'!
!MinMaxEditor methodsFor: 'controller access'!
defaultControllerClass
"Answer the class of the default controller for the receiver."
^MinMaxController! !
!MinMaxEditor methodsFor: 'text'!
textMenu
"Answer an ActionMenu of operations on the text of the selected
variable's value that is to be displayed when the operate menu
button is pressed."
MinMaxTextMenu == nil ifTrue:
[MinMaxTextMenu _
ActionMenu
labels: 'reset to default\again\undo\copy\cut\paste\do it\print it\inspect\accept\cancel' withCRs
lines: #(1 3 6 9)
selectors: #(#resetToDefault #again #undo #copySelection #cut #paste #doIt #printIt #inspectIt #accept #cancel )].
^MinMaxTextMenu! !
!MinMaxEditor methodsFor: 'field list'!
fieldIndex
"Answer the offset corresponding to the currently selected field"
field = 'minimum'
ifTrue: [^1].
field = 'maximum'
ifTrue: [^2].
^nil!
fieldList
"Answer an Array consisting of minimum and maximum."
FieldList = nil
ifTrue: [FieldList _ Array with: 'minimum' with: 'maximum'].
^FieldList.!
fieldMenu
"Answer an ActionMenu of operations on the variables that is to be displayed
when the operate menu button is pressed."
^nil.!
fieldValue
"Answer the value of the currently selected variable."
field = 'minimum' ifTrue: [^minimum].
field = 'maximum' ifTrue: [^maximum].
^nil.! !
!MinMaxEditor methodsFor: 'menu messages'!
resetToDefault
| min aString max aStream |
field = 'minimum' ifTrue: [box minimumValueIsDefault
ifFalse:
[box minimumValue: nil.
min _ box minimumValue.
min = nil
ifTrue: [aString _ 'default (known after simulation)']
ifFalse: [aString _ 'default (' .
aStream _ TextStream on: ''.
min printOn: aStream.
aString _ aString, aStream contents asString, ')'].
minimum _ aString asSymbol]].
field = 'maximum' ifTrue: [box maximumValueIsDefault
ifFalse:
[box maximumValue: nil.
max _ box maximumValue.
max = nil
ifTrue: [aString _ 'default (known after simulation)']
ifFalse: [aString _ 'default (' .
aStream _ TextStream on: ''.
max printOn: aStream.
aString _ aString, aStream contents asString, ')'].
maximum _ aString asSymbol]].
self changed: #text.!
update
^self!
updateBoxMinMaxValues
minimum isSymbol
ifTrue: ["set to default"
box minimumValue: nil]
ifFalse: [box minimumValue: minimum].
maximum isSymbol
ifTrue: ["set to default"
box maximumValue: nil]
ifFalse: [box maximumValue: maximum]! !
!MinMaxEditor methodsFor: 'initialize-release'!
forBox: aBox
| min aString max aStream |
aBox = nil
ifTrue: [^nil].
box _ aBox.
aBox minimumValueIsDefault
ifTrue:
[min _ box minimumValue.
min = nil
ifTrue: [aString _ 'default (known after simulation)']
ifFalse: [aStream _ TextStream on: ''.
min printOn: aStream.
aString _ 'default (', aStream contents asString, ')'].
minimum _ aString asSymbol]
ifFalse: [minimum _ box minimumValue].
aBox maximumValueIsDefault
ifTrue:
[max _ box maximumValue.
max = nil
ifTrue: [aString _ 'default (known after simulation)']
ifFalse: [aStream _ TextStream on: 'default('.
max printOn: aStream.
aString _ 'default (',aStream contents asString, ')'].
maximum _ aString asSymbol]
ifFalse: [maximum _ box maximumValue].
self changed: #field!
initialize
field _ nil.
self changed: #field.!
update: anAspect with: aParameter
anAspect = #forBox:
ifTrue: [self forBox: aParameter].
anAspect = #currentBox
ifTrue: [self initialize].! !
!MinMaxEditor methodsFor: 'doIt/accept/explain'!
acceptText: aText from: aController
"Text has been changed. Store or compile the text, depending on
the current mode of the receiver."
| val |
object class == CompiledMethod ifTrue: [^false].
field == nil ifTrue: [^false].
val _ self
evaluateText: aText string
from: aController
ifFail: [^false].
field = 'minimum'
ifTrue:
[minimum _ val.
box minimumValue: val].
field = 'maximum'
ifTrue:
[maximum _ val.
box maximumValue: val].
self changed: #text.
^true! !
!MinMaxEditor methodsFor: 'accessing'!
box
^box! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
MinMaxEditor class
instanceVariableNames: ''!
!MinMaxEditor class methodsFor: 'instance creation'!
forBox: aBox
MinMaxView open: (self new forBox: aBox).! !
!MinMaxEditor class methodsFor: 'class initialization'!
flushMenu
FieldList _ nil.! !
StandardSystemController subclass: #MinMaxController
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'SDS-Graphs'!
MinMaxController comment:
'Controller for triad MinMaxEditor (model) - MinMaxView (view) - MinMaxController (controller)
'!
!MinMaxController methodsFor: 'menu messages'!
resetToDefault
model resetToDefault.! !